#region Namespace References

using System;
using DynConDevCorp.OpenArch.SmartData.Interfaces.EventArgClasses;

#endregion

namespace DynConDevCorp.OpenArch.SmartData.Interfaces
{
    /// <summary>
    /// Base Interface for all Smart Fields (A Smart Field holds a single ccalar Value)
    /// </summary>
    public interface ISmartField : ISmartBase
    {
        #region Public Instance Properties

        /// <summary>
        /// Sets the input value.
        /// </summary>
        /// <value>The input value.</value>
        string InputValue { set; }

        /// <summary>
        /// Gets the display value.
        /// </summary>
        /// <value>The display value.</value>
        string DisplayValue { get; }

        /// <summary>
        /// Gets or sets the display format string.
        /// </summary>
        /// <value>The display format string.</value>
        string DisplayFormatString { get; set;}

        /// <summary>
        /// Gets or sets a value indicating whether [input inhibited].
        /// </summary>
        /// <value><c>true</c> if [input inhibited]; otherwise, <c>false</c>.</value>
        PartialBoolean InputInhibited { get; set; }
        /// <summary>
        /// Gets or sets a value indicating whether [read only].
        /// </summary>
        /// <value><c>true</c> if [read only]; otherwise, <c>false</c>.</value>
        PartialBoolean WriteLocked { get; set; }

        /// <summary>
        /// Gets or sets the raw value.
        /// </summary>
        /// <value>The raw value.</value>
        object RawValue { get; set; }

        /// <summary>
        /// Gets the type of the data.
        /// </summary>
        /// <value>The type of the data.</value>
        Type DataType { get; }

          #endregion

        #region Public Instance Methods

        /// <summary>
        /// Formatteds the display.
        /// </summary>
        /// <param name="format">The format.</param>
        /// <returns></returns>
        string FormattedDisplay(string format);

        /// <summary>
        /// Enables the track changes.
        /// </summary>
        /// <param name="state">if set to <c>true</c> [state].</param>
        void EnableTrackChanges(bool state);

        /// <summary>
        /// Gets a value indicating whether [track changes].
        /// </summary>
        /// <value><c>true</c> if [track changes]; otherwise, <c>false</c>.</value>
        PartialBoolean TrackingChanges { get; }


        /// <summary>
        /// Marks as dirty.
        /// </summary>
        void MarkAsDirty();

        /// <summary>
        /// Gets a value indicating whether this instance is dirty.
        /// </summary>
        /// <value><c>true</c> if this instance is dirty; otherwise, <c>false</c>.</value>
        PartialBoolean IsDirty { get; }

        /// <summary>
        /// Commits this instance.
        /// </summary>
        void Commit();

        /// <summary>
        /// Rollback value to last Committed Value.
        /// </summary>
        void Rollback();

        #endregion

        #region All Other Members

        /// <summary>
        /// Occurs when [raw value changed].
        /// </summary>
        event EventHandler<ValueChangedEventArgs<object>> RawValueChanged;

        /// <summary>
        /// Occurs when [display value changed].
        /// </summary>
        event EventHandler<DisplayValueChangedEventArgs> DisplayValueChanged;

        #endregion

    }

   
    /// <summary>
    /// Type Safe Interface for all Smart Fields (A Smart Field holds a single Value of the specialization type)
    /// </summary>
    /// <typeparam name="TData">The type of the AT a_ TYPE.</typeparam>
    public interface ISmartField<TData> : ISmartField
        where TData : IComparable<TData>
    {
        #region Public Instance Properties

        /// <summary>
        /// Gets or sets the input parser.
        /// </summary>
        /// <value>The input parser.</value>
        ISmartInputParser<TData> InputParser { get; set; }

        /// <summary>
        /// Gets or sets the display formatter.
        /// </summary>
        /// <value>The display formatter.</value>
        ISmartDisplayFormatter<TData> DisplayFormatter { get; set; }

        /// <summary>
        /// Gets or sets the value.
        /// </summary>
        /// <value>The value.</value>
        TData Value { get; set; }

        #endregion

        #region Public Instance Methods

        #endregion

        #region All Other Members

        /// <summary>
        /// Adds the effect.
        /// </summary>
        /// <param name="effect">The effect.</param>
        void AddEffect(ISmartEffect<TData> effect);

        /// <summary>
        /// Removes the effect.
        /// </summary>
        /// <param name="effect">The effect.</param>
        void RemoveEffect(ISmartEffect<TData> effect);


        /// <summary>
        /// Adds the rule.
        /// </summary>
        /// <param name="rule">The rule.</param>
        void AddRule(ISmartRule<TData> rule);

        /// <summary>
        /// Removes the rule.
        /// </summary>
        /// <param name="rule">The rule.</param>
        void RemoveRule(ISmartRule<TData> rule);


        /// <summary>
        /// Occurs when [value changed].
        /// </summary>
        event EventHandler<ValueChangedEventArgs<TData>> ValueChanged;

         #endregion
    }
}